package com.bkrebs.moneybud;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Vector;

public class Database {
	private Vector<String> vCategories;
	private Vector<Dataset> vMyData;
	private Vector<String> vIncFiles;

	public Database() {
		vCategories = new Vector<String>();
		vMyData = new Vector<Dataset>();
		vIncFiles = new Vector<String>();
	}

	public int getSize() {
		return vMyData.size();
	}

	public void includeData(List<String[]> data, short mode) {
		// 0 SPK 1 DKB 2 AMEX

		if (mode == 0) { // parsing sparkassenformat
			for (int i = 1; i < data.size(); i++) {
				Dataset myDataset = new Dataset();

				try {
					myDataset.dtDate = new SimpleDateFormat("dd.MM.yy")
							.parse(data.get(i)[2]);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}

				myDataset.strPurpose = data.get(i)[4];
				myDataset.strPartner = data.get(i)[5];
				myDataset.strKto = data.get(i)[6];
				myDataset.strBlz = data.get(i)[7];
				myDataset.flAmount = Float.valueOf(data.get(i)[8].replace(",",
						"."));
				vMyData.add(myDataset);
			}
		} else if (mode == 1) {
			for (int i = 8; i < data.size(); i++) {
				Dataset myDataset = new Dataset();

				try {
					myDataset.dtDate = new SimpleDateFormat("dd.MM.yyyy")
							.parse(data.get(i)[1]);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				myDataset.strPurpose = data.get(i)[3];
				myDataset.flAmount = Float.valueOf(data.get(i)[4].replace(",",
						"."));
				vMyData.add(myDataset);
			}
		} else if (mode == 2) {
			for (int i = 0; i < data.size(); i++) {
				for (int j = 0; j < data.get(i).length; j++) {
					System.out.println(data.get(i)[j]);
				}
			}
		}

	}
}
